package iit.projects.etaxi.model.service;

import java.util.TimerTask;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ProcessNoResponseTimerService extends TimerTask {
	
	final Logger log = LoggerFactory.getLogger(ProcessNoResponseTimerService.class);
	
	private ReservationService reservationService;

	@Override
	public void run() {
		
		if(log.isTraceEnabled()){
			log.trace("Executing Run on ProcessNoResponseTimerService");
		}
		
		long startTime = 0;
		startTime = System.currentTimeMillis();
		if(log.isDebugEnabled()){
			log.debug("Started Processing No Reply Reservations at " + startTime);
		}
		
		try{
			reservationService.processNoReplySms();
		}catch(Throwable e){
			log.error("ERROR : " + e);
		}
		
		if(log.isDebugEnabled()){
			log.debug("Time taken for Processing No Reply Reservations = " + 
					(System.currentTimeMillis() - startTime) + "ms");
		}
	}

	public void setReservationService(ReservationService reservationService) {
		this.reservationService = reservationService;
	}

}
